import { DatePicker } from "antd"
import { FC, useState } from "react"

import { ICommonDatePickerProps } from "./types"

const CommonDatePicker: FC<ICommonDatePickerProps> = props => {
	const [value, setValue] = useState<ICommonDatePickerProps["defaultValue"]>(props.defaultValue)
	const onChange: ICommonDatePickerProps["onChange"] = (date, _str) => {
		console.log(date, _str)
		setValue(date as ICommonDatePickerProps["defaultValue"])
	}
	return <DatePicker.RangePicker {...props} value={value} onChange={onChange} />
}

export default CommonDatePicker
